<?php
	@mysql_pconnect('localhost', 'root', '');
	@mysql_select_db('studial');
	if(isset($_GET['id']))
	{
		$course_id = $_GET['id'];
		$result = mysql_query("select * from `courses` where `id` = '".$course_id."';");
		$rows = mysql_fetch_array($result);
		$amdin_id = $rows['administrator_id'];
		$user_id = $_COOKIE['studialuserid'];
		if($amdin_id == $user_id)
		{
			@mysql_query("delete from `enroll` where `course_id` = '".$course_id."';");
			@mysql_query("delete from `courses` where `id` = '".$course_id."';");	
			header ("Location: courselist.php?id=".$user_id);
		}
			
	}
?>